package org.andromda.cartridges.gwt.metafacades;

import org.andromda.metafacades.uml.DependencyFacade;
import org.andromda.metafacades.uml.Entity;
import org.andromda.metafacades.uml.FilteredCollection;
import org.andromda.metafacades.uml.ModelElementFacade;
import org.andromda.metafacades.uml.ServiceOperation;
import org.andromda.metafacades.uml.ValueObject;
import org.apache.log4j.Logger;

/**
 * MetafacadeLogic implementation for org.andromda.cartridges.gwt.metafacades.GwtDataDetail.
 * 
 * @see org.andromda.cartridges.gwt.metafacades.GwtDataDetail
 */
public class GwtDataDetailLogicImpl extends GwtDataDetailLogic {

	/**
	 * The logger instance.
	 */
	private static final Logger	logger	= Logger.getLogger( GwtDataDetailLogicImpl.class );

	public GwtDataDetailLogicImpl(Object metaObject, String context) {
		super( metaObject, context );
	}

	/**
	 * @see org.andromda.cartridges.gwt.metafacades.GwtDataDetail#getServiceOperation()
	 */
	@Override
	protected java.lang.Object handleGetServiceOperation() {
		return new FilteredCollection( this.getSourceDependencies() ) {
			@Override
			public boolean evaluate(final Object object) {
				ModelElementFacade targetElement = ( ( DependencyFacade ) object ).getTargetElement();
				return ( targetElement != null ) && ServiceOperation.class.isAssignableFrom( targetElement.getClass() );
			}
		};
	}

	@Override
	protected Object handleGetRelatedEntity() {
		return new FilteredCollection( this.getSourceDependencies() ) {
			@Override
			public boolean evaluate(final Object object) {
				ModelElementFacade targetElement = ( ( DependencyFacade ) object ).getTargetElement();
				return ( targetElement != null ) && Entity.class.isAssignableFrom( targetElement.getClass() );
			}
		};
	}

	@Override
	protected String handleGetFieldDefs() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected ValueObject handleGetRelatedDTO() {
		// TODO Auto-generated method stub
		return null;
	}

}